<template>
  <div class="product-show">
    <div v-if="loading" v-loading="loading" style="height: 100%"></div>
    <template v-if="type === 'scroll'">
      <GeminiScrollbar class="shit">
        <ProductCard v-for="(item, index) in productList" :productInfo="item" :key="index" />
      </GeminiScrollbar>
    </template>
    <template v-else>
      <ProductCard v-for="(item, index) in productList" :productInfo="item" :key="index" />
    </template>
  </div>
</template>

<script>
import api from "@/api.js";
import ProductCard from "@/components/ProductCard.vue";
export default {
  props: {
    type: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      productList: [],
      loading: false,
    };
  },
  components: {
    ProductCard
  },
  created() {
    this.getProductList();
  },
  methods: {
    async getProductList() {
      this.loading = true;
      const { data } = await api.getProductList();
      this.productList = data;
      this.loading = false;
    }
  }
};
</script>

<style lang="scss">
.product-show {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 25px;
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;

  .shit {
    height: 350px;
    .gm-scroll-view {
      display: flex;
      & > * {
        flex-shrink: 0;
      }
    }
  }
}
</style>
